package com.sky.mapper;

import com.sky.annotation.AutoFill;
import com.sky.entity.Category;
import com.sky.enumeration.OperationType;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author 衷岚
 * @version 1.0
 */
@Mapper
public interface CategoryMapper {

    @Insert("insert into category(type, name, sort, status, create_time, update_time, create_user, update_user) " +
            "VALUES (#{type},#{name},#{sort},#{status},#{createTime},#{updateTime},#{createUser},#{updateUser})")
    @AutoFill(OperationType.INSERT)
    void add(Category category);

    @Update("update category set type=#{type},name=#{name},sort=#{sort},update_time=#{updateTime},update_user=#{updateUser} where id=#{id}")
    @AutoFill(OperationType.UPDATE)
    void update(Category category);

    @Delete("delete from category where id=#{id}")
    void deleteById(Long id);


    @Update("update category set status=#{status},update_user=#{updateUser},update_time=#{updateTime} where id=#{id}")
    @AutoFill(OperationType.UPDATE)
    void updateStatus(Category category);

    List<Category> list(Category category);


    List<Category> findByType(Integer type);
}
